-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to bundle node externals when using Yarn Workspaces #494
Comments
Holy moly I solved it..
It makes solve all of errors and warnings. I was struggled in this issue almost whole three days... Anyway, I will close it. |
Hi @jormal, thanks for opening the issue, sorry for the late response, glad you managed to find a workaround. I think this might be worth adding to the documentation, so I'll re-open the issue with a new title. |
(EDITED) I solved it by fixing config. But, I have tiny another issue. I think it should be announced to you.
After bundling, in fetching dependency, caused another warnings about disable of determining version.
Web3 has dependency on package, not root. So, It was excepted in "root/package.json", on the other hands, it was contained in "root/packages/eth/package.json" It doesn't look like affecting anything in operation right now. But, I worried about it would be cause of trouble in maintenance. |
This actually is a problem and you can't support workspaces. This is due to the fact you bypass node externals rather than listening to it. We need to be able to provide an array of Ideally you would just follow node externals - not sure why this is custom. Another option is to look for the Either way not sure why defining the proper externals in my webpack config is not actually making those external unless i then also do node externals in the serverless-webpack config
externals: [
'aws-sdk',
nodeExternals({
modulesDir: path.resolve(path.dirname(rootDir), 'shared'),
}),
nodeExternals({
modulesDir: path.dirname(rootDir),
}),
nodeExternals({
modulesDir: rootDir,
}),
], but i cant provide all 3 paths again to serverless-webpack. It would be better to just follow the externals property and use that. This is required because of the following config which allows defining other module directories resolve: {
modules: [
path.resolve(`${rootDir}/../shared`),
path.resolve(`${rootDir}/../node_modules`),
'node_modules',
],
}, |
Any update on this, I'm new to Yarn Workspaces and
I tried the above option (updating to hit my top level
But still no luck. Just curious if there is anything obvious to allow |
I have also been running into these same issues the past few days. I think I've solved the internal package not found issue but whitelisting it in externals: [nodeExternals({ whitelist: ["internal-package"] })] This ensures webpack pulls the local version of your internal package. However, I have not found a good workaround for Has anyone found a workaround or poked into supporting yarn workspaces? I'm thinking about ditching workspaces in the near future as I've spent too much time running in circles looking for workarounds 😅 |
@Tybot204 Same here..... so frustrated to work with workspaces... keep hoping for library X to support it... while now yarn is promoting pnp 😅... What tool set would you go for if you ditched workspace? nx? lerna? |
@juuyan Yarn workspaces are not compatible with pnp mode. |
… doesnt work well with yarn workspaces. Serverless reports module not found. This is due to a workaround to get serverless-webpack to work, but the node externals does not include the module https://github.com/serverless-heaven/serverless-webpack/issues/494\#issuecomment-637244350
you sir, save my day! |
Here is a Webpack config that works for my serverless app that uses Yarn Workspaces. This app deploys to AWS. It is far from perfect but it does work. Hope it helps someone. mode: slsw.lib.webpack.isLocal ? "development" : "production",
entry: slsw.lib.entries,
target: "node",
externals: [
{
"aws-sdk": "commonjs aws-sdk",
bufferutil: "commonjs bufferutil",
"utf-8-validate": "commonjs utf-8-validate",
},
],
plugins: [
new ProgressBarPlugin(),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
"process.env.FLUENTFFMPEG_COV": false,
}),
],
optimization: {
minimize: false,
usedExports: true,
},
performance: {
hints: false,
},
stats: {
colors: true,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
sideEffects: false,
use: {
loader: "babel-loader",
options: {
comments: false,
cacheDirectory: true,
presets: [
[
"@babel/preset-env",
{
targets: { node: "current" },
modules: false,
debug: false,
shippedProposals: true,
useBuiltIns: "usage",
corejs: "3.9",
},
],
],
},
},
},
],
},
}; |
I've switched to https://github.com/AnomalyInnovations/serverless-bundle and it makes my life easier. |
Are you using Yarn 2 with workspaces? |
This is a Bug Report
Description
For bug reports:
When I was using only one package, web3 could be bundled successfully.
But, I needed to restruct my project to using yarn workspace. So, I only restructed (not code edited) my project and I came across some bundling errors.
This error seems like same error in #224. But, that error of this issue is not solved..
I think it depend with #438, serverless-webpack couldn't follow the mono-repo structure.
What did you expect should have happened?
I want to know the way to fixing it temporarily or supporting yarn workspace permanently.
What was the config you used?
.bablerc
It caused at
Serverless: Bundling with Webpack...
And make message
Webpack compilation error, see above
And also,
SLS_DEBUG=*
makes no difference.Skipped warnings are
Similar or dependent issue(s):
Additional Data
The text was updated successfully, but these errors were encountered: